/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author Jirka
 */
@Entity
@Table(name = "offer")
@NamedQueries({@NamedQuery(name = "Offer.findAll", query = "SELECT o FROM Offer o"), @NamedQuery(name = "Offer.findByMoney", query = "SELECT o FROM Offer o WHERE o.money = :money"), @NamedQuery(name = "Offer.findByOfferId", query = "SELECT o FROM Offer o WHERE o.offerId = :offerId")})
public class Offer implements Serializable {
    private static final long serialVersionUID = 1L;
    @Column(name = "money")
    private Integer money;
    @Id
    @Basic(optional = false)
    @Column(name = "offer_id")
    @GeneratedValue(strategy=GenerationType.SEQUENCE)
    private Integer offerId;
    @JoinColumn(name = "club_id", referencedColumnName = "club_id")
    @ManyToOne(optional = false)
    private Club club;
    @JoinColumn(name = "player_id", referencedColumnName = "player_id")
    @ManyToOne(optional = false)
    private Player player;

    public Offer() {
    }

    public Offer(Integer offerId) {
        this.offerId = offerId;
    }

    public Integer getMoney() {
        return money;
    }

    public void setMoney(Integer money) {
        this.money = money;
    }

    public Integer getOfferId() {
        return offerId;
    }

    public void setOfferId(Integer offerId) {
        this.offerId = offerId;
    }

    public Club getClub() {
        return club;
    }

    public void setClub(Club club) {
        this.club = club;
    }

    public Player getPlayer() {
        return player;
    }

    public void setPlayer(Player player) {
        this.player = player;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (offerId != null ? offerId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Offer)) {
            return false;
        }
        Offer other = (Offer) object;
        if ((this.offerId == null && other.offerId != null) || (this.offerId != null && !this.offerId.equals(other.offerId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.Offer[offerId=" + offerId + "]";
    }

}
